/**
 * Created by hxb on 2017/2/8.
 */
import navConfig from './route.config.json'

const registerRoute = (config) => {
  let route = []
  function addRoute (page) {
    const component = require(`./pages${page.path}.vue`)
    let child = {
      name: page.name,
      path: page.path.slice(0),
      meta: {
        title: page.title || page.name,
        description: page.description
      },
      components: {
        content: component
      }
    }
    route.push(child)
  }
  config
    .map(nav => {
      if (nav.path) {
        addRoute(nav)
      }
      if (nav.children) {
        nav.children.map(child => {
          addRoute(child)
        })
      }
    })
  return { route, navs: config }
}

const route = registerRoute(navConfig)

let indexRoute = [{
  name: '/',
  path: '/',
  components: {
    main: require('./pages/Home.vue')
  },
  children: route.route
}, {
  name: 'index',
  path: '/index',
  components: {
    main: require('./components/HelloFromVux.vue')
  }
}, {
  name: '专题Type首页商品专题详情',
  path: '/typeSpecial',
  components: {
    main: require('./pages/content/shoppingMall/typeSpecial.vue')
  }
}, {
  name: '商品自定义专题详情',
  path: '/shopSpecial',
  components: {
    main: require('./pages/content/shoppingMall/shopSpecial.vue')
  }
}, {
  name: 'ShopInfo',
  path: '/ShopInfo',
  components: {
    main: require('./pages/content/shoppingMall/ShopInfo.vue')
  }
}, {
  name: 'UserIndex',
  path: '/UserIndex',
  components: {
    main: require('./pages/content/user/User.vue')
  }
}, {
  name: '抽奖',
  path: '/Luck',
  components: {
    main: require('./pages/content/activities/Luck.vue')
  }
}, {
  name: '钱包',
  path: '/UserWallet',
  components: {
    main: require('./pages/content/user/UserWallet.vue')
  }
}, {
  name: '我的收藏',
  path: '/UserCollection',
  components: {
    main: require('./pages/content/user/UserCollection.vue')
  }
}, {
  name: '卡券包',
  path: '/UserCoupons',
  components: {
    main: require('./pages/content/user/UserCoupons.vue')
  }
}, {
  name: '收货地址',
  path: '/UserAddress',
  components: {
    main: require('./pages/content/user/UserAddress.vue')
  }
}, {
  name: '邀请好友',
  path: '/UserInvitation',
  components: {
    main: require('./pages/content/user/UserInvitation.vue')
  }
}, {
  name: '我的积分',
  path: '/pionts/PiontsIndex',
  components: {
    main: require('./pages/content/user/pionts/PiontsIndex.vue')
  }
}, {
  name: '提现记录',
  path: '/pionts/CashRecord',
  components: {
    main: require('./pages/content/user/pionts/CashRecord.vue')
  }
}, {
  name: '余额主页',
  path: '/remainder/RemainderIndex',
  components: {
    main: require('./pages/content/user/remainder/RemainderIndex.vue')
  }
}, {
  name: '分销记录',
  path: '/distribution/DistributionIndex',
  components: {
    main: require('./pages/content/user/distribution/DistributionIndex.vue')
  }
}, {
  name: '开通会员',
  path: '/member/GetMember',
  components: {
    main: require('./pages/content/user/member/GetMember.vue')
  }
}, {
  name: '积分明细',
  path: '/pionts/Detail',
  components: {
    main: require('./pages/content/user/pionts/Detail.vue')
  }
}, {
  name: '积分兑现',
  path: '/pionts/IntegralCash',
  components: {
    main: require('./pages/content/user/pionts/IntegralCash.vue')
  }
}, {
  name: '余额提现',
  path: '/remainder/RemainderCash',
  components: {
    main: require('./pages/content/user/remainder/RemainderCash.vue')
  }
}, {
  name: '余额明细',
  path: '/remainder/Detail',
  components: {
    main: require('./pages/content/user/remainder/Detail.vue')
  }
}, {
  name: '申请额外兑现',
  path: '/pionts/ExtraCash',
  components: {
    main: require('./pages/content/user/pionts/ExtraCash.vue')
  }
}, {
  name: '申请记录',
  path: '/pionts/ApplicationRecord',
  components: {
    main: require('./pages/content/user/pionts/ApplicationRecord.vue')
  }
}, {
  name: '结算界面',
  path: '/shoppingCar/Clean',
  components: {
    main: require('./pages/content/shoppingCar/CleanShoppingCar.vue')
  }
}, {
  name: '结算界面-选择地址',
  path: '/shoppingCar/SelectAddress',
  components: {
    main: require('./pages/content/shoppingCar/cleanShop/SelectAddress.vue')
  }
}, {
  name: '结算界面-积分抵扣',
  path: '/shoppingCar/SelectScore',
  components: {
    main: require('./pages/content/shoppingCar/cleanShop/SelectScore.vue')
  }
}, {
  name: '结算界面-支付界面',
  path: '/shoppingCar/shoppingBuy',
  components: {
    main: require('./pages/content/shoppingCar/cleanShop/shoppingBuy.vue')
  }
}, {
  name: '添加地址',
  path: '/address/AddAddress',
  components: {
    main: require('./pages/content/user/address/AddAddress.vue')
  }
}, {
  name: '详细地址',
  path: '/address/AddressDetail',
  components: {
    main: require('./pages/content/user/address/AddressDetail.vue')
  }
}, {
  name: '选择省份',
  path: '/ChinaAddress',
  components: {
    main: require('./pages/content/shoppingMall/ChinaAddress.vue')
  }
}, {
  name: '搜索商品',
  path: '/SearchShop',
  components: {
    main: require('./pages/content/shoppingMall/SearchShop.vue')
  }
}, {
  name: '签到',
  path: '/SignDay',
  components: {
    main: require('./pages/content/activities/SignDay.vue')
  }
}, {
  name: '所有订单',
  path: '/order/OrderIndex',
  components: {
    main: require('./pages/content/user/order/OrderIndex.vue')
  }
}, {
  name: '订单详情',
  path: '/order/OrderDetail',
  components: {
    main: require('./pages/content/user/order/OrderDetail.vue')
  }
}, {
  name: '申请退款',
  path: '/order/OrderRefund',
  components: {
    main: require('./pages/content/user/order/OrderRefund.vue')
  }
}, {
  name: '退款',
  path: '/order/RefundInfo',
  components: {
    main: require('./pages/content/user/order/RefundInfo.vue')
  }
}, {
  name: '退款详情',
  path: '/order/RefundDetail',
  components: {
    main: require('./pages/content/user/order/RefundDetail.vue')
  }
}, {
  name: '完善资料',
  path: '/UserInformation',
  components: {
    main: require('./pages/content/user/UserInformation.vue')
  }
}, {
  name: '积分兑换界面',
  path: '/ScoreShop',
  components: {
    main: require('./pages/content/activities/ScoreShop.vue')
  }
}, {
  name: '会员权益',
  path: '/member/Rights',
  components: {
    main: require('./pages/content/user/member/Rights.vue')
  }
}, {
  name: '余额提现记录',
  path: '/remainder/RemainderRecord',
  components: {
    main: require('./pages/content/user/remainder/RemainderRecord.vue')
  }
}, {
  name: '立即购买界面',
  path: '/shopMain/goShopBuy',
  components: {
    main: require('./pages/content/shoppingMall/goShopBuy.vue')
  }
}, {
  name: '开通会员支付',
  path: '/member/PayMember',
  components: {
    main: require('./pages/content/user/member/PayMember.vue')
  }
}, {
  name: '分享页面',
  path: '/UserShare',
  components: {
    main: require('./pages/content/user/UserShare.vue')
  }
}, {
  name: '生日提醒首页',
  path: '/UserBirthday',
  components: {
    main: require('./pages/content/user/UserBirthday.vue')
  }
}, {
  name: '新增编辑生日提醒',
  path: '/birthday/AddBirthday',
  components: {
    main: require('./pages/content/user/birthday/AddBirthday.vue')
  }
}, {
  name: '商品-服务列表界面',
  path: '/shoppingMall/serviceShopList',
  components: {
    main: require('./pages/content/shoppingMall/serviceShopList.vue')
  }
}, {
  name: '个人领奖纪录',
  path: '/activities/luckRecode',
  components: {
    main: require('./pages/content/activities/luckRecode.vue')
  }
}, {
  name: '查看物流',
  path: '/order/OrderLogistics',
  components: {
    main: require('./pages/content/user/order/OrderLogistics.vue')
  }
}]
// indexRoute = indexRoute.concat(route.route)
export const navs = route.navs
export default indexRoute
